﻿using System;
using System.Collections.Generic;


public class EntityManager<ENTITY_TYPE>
{
    public EntityManager()
    {
    }

    public bool Add(ENTITY_TYPE aEntity)
    {
        // check already exist

        m_list.Add(aEntity);
        return true; 
    }

    public void Remove(ENTITY_TYPE aEntity)
    {
        // 
    }

    public void RemoveAt(int slot)
    {
        //
    }

    public TurnManager TurnManager()
	{
        return m_turnManager;
	}

    // members 
    protected TurnManager m_turnManager = new TurnManager();
    protected List<ENTITY_TYPE> m_list = new List<ENTITY_TYPE>();

    protected JoyUtil m_util = new JoyUtil(); // for time, random
}


public class PlayerParty : EntityManager<Character>
{
    public PlayerParty()
    {
    }

    public void Update(double deltaTime)
    {
        //update turn
        m_turnManager.Update(deltaTime);
        foreach (Character entity in m_list) 
        {
            // buff time update
            entity.Update(deltaTime);
        }
    }

    public Character Select()
    {
        int slot = m_util.RandomRange(0, m_list.Count);
        return m_list[slot];
    }

    public Character SelectTarget()
    {
        int slot = m_util.RandomRange(0, m_list.Count);
        return m_list[slot];
    }
   
}

public class MonsterGroup : EntityManager<Monster>
{
    public MonsterGroup()
    {
    }

    public void Update(double deltaTime)
    {
        //update turn
        m_turnManager.Update(deltaTime);
        foreach (Monster entity in m_list) 
        {
            // buff time update
            entity.Update(deltaTime);
        }
    }

    public Monster Select()
    {
        int slot = m_util.RandomRange(0, m_list.Count);
        return m_list[slot];
    }

    public Monster SelectTarget()
    {
        int slot = m_util.RandomRange(0, m_list.Count);
        return m_list[slot];
    }
}

